﻿@model BlankMvc.Types.UserLogin
<div class="modal fade" id="modalLoginForm" tabindex="-1" role="dialog" data-backdrop="false">
    <div class="modal-dialog">
        @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal modal-content", role = "form", id = "loginFormId" })) {
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Пожалуйста авторизуйтесь</h4>
            </div>
            <div class="modal-body">
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)
                <div class="form-group">
                    @Html.LabelFor(m => m.UserName, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(m => m.UserName)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(m => m.Password, new { @class = "col-md-4 control-label" })
                    <div class="col-lg-6">
                        <div class="input-group ">
                            @Html.PasswordFor(m => m.Password, new { @class = "form-control pwd" })
                            <span class="input-group-btn">
                                <button class="btn btn-default reveal" type="button"><i class="glyphicon glyphicon-eye-open"></i></button>
                            </span>
                        </div>
                        @Html.ValidationMessageFor(m => m.Password)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <div class="checkbox">
                            @Html.CheckBoxFor(m => m.RememberMe)
                            @Html.LabelFor(m => m.RememberMe)
                        </div>
                    </div>
                </div>
                <p>
                    @Html.ActionLink("Регистрация", "RegisterForm", null, new { Class = "dax", @data_dismiss = "modal", @aria_hidden = "false" }), если у вас нет аккаунта.
                </p>
            </div>
            <div class="modal-footer">
                <input type="submit" value="Авторизация" class="btn btn-primary" />
                <button type="button" class="btn btn-default" data-dismiss="modal">Отмена</button>
            </div>
        }
    </div>
</div>

<script type="text/javascript">
    $('#modalLoginForm').modal('show');
    $.validator.unobtrusive.parse($("#loginFormId"));
    $('#loginFormId .reveal').mousedown(function() {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'text'));
    }).bind('mouseup mouseout', function () {
        var inp = $(this).closest('.input-group').find('.pwd');
        inp.replaceWith(inp.clone().attr('type', 'password'));
    });
</script>